HAL JPEG migration: list of applicable concepts

This section provides information about the HAL JPEG architecture concepts relevant to STM32 HAL1 to HAL2 migration.

Concepts for JPEG

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate init and config functions:

  • HAL_JPEG_Init(): initializes the handle and links it to a JPEG instance.

  • HAL_JPEG_SetConfigEncoding(): sets the configuration for the encoding process.

Removal and conversion of init structure to configuration structure

The init structure JPEG_ConfTypeDef has been removed and moved into hal_jpeg_config_t configuration structure.

Renaming of the handle structure

The handle structure has been renamed to hal_jpeg_handle_t.

Renaming unitary init structures

The structure JPEG_ConfTypeDef is no longer available and has been replaced by hal_jpeg_config_t.

Remove MspInit and MspDeInit callbacks

HAL_JPEG_MspInit() and HAL_JPEG_MspDeInit() are no longer available. They have to be replaced by a user-defined sequence to initialize and configure the JPEG.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro has been replaced by new functions HAL_JPEG_SetTxDMA() and HAL_JPEG_SetRxDMA() to link a JPEG HAL handle to a DMA HAL handle.

Introduction of HAL user data set/get APIs

Two functions to set/get user data are available: HAL_JPEG_SetUserData() and HAL_JPEG_GetUserData().

Individual callback registration APIs replace global register and unregister functions

The registration of callbacks for JPEG events is managed by dedicated functions. Each function is responsible for registering callback functions for specific JPEG events.

Removal of hardware-related macros in HAL2

All public macros have been removed from the HAL JPEG driver and replaced with static inline APIs.

Revised and optimized HAL state machine

The JPEG has now been managed by two states :

  • Global state machine

  • Encode configuration state machine

Revised and optimized HAL API status returns

The HAL JPEG functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

The error handling mechanisms within the HAL have been redesigned to enhance the detection, reporting, and management of errors.

Removal of underscore prefixes for macros

All underscore prefixes in JPEG have been removed.

Replaced TypeDef suffix with _t in type names

All TypeDef parts in JPEG have been removed and replaced by _t.

Assertion implementation and usage in HAL1

The ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros are used to check the parameters and state of the HAL JPEG driver.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including JPEG instances) have been converted into enumerated types (enums) at the HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL JPEG functions start with HAL_JPEG.